package thread;

public class syncDemo3 {
    public static void main(String[] args) {
        Boo b1=new Boo();
        Boo b2=new Boo();
        Thread t1=new Thread(){
            @Override
            public void run() {
                Boo.dosome();
                b1.dosome();

            }
        };
        Thread t2=new Thread(){
            @Override
            public void run() {
                Boo.dosome();
                b2.dosome();

            }
        };
       t1.start();
       t2.start();
    }
    static class Boo{
        public synchronized static void dosome(){
            try {
                Thread t=Thread.currentThread();
                System.out.println(t.getName()+"正在执行dosome方法。。。。");
                Thread.sleep(5000);
                System.out.println(t.getName()+"执行desome方法完毕");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}
